package com.qdlc.p2p.manage.action;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;

import com.opensymphony.xwork2.ModelDriven;
import com.qdlc.p2p.biz.service.NoticeService;
import com.qdlc.p2p.biz.web.action.BaseAction;
import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.common.model.jpa.PageDataList;
import com.qdlc.p2p.dal.model.NoticeModel;

/**
 * 消息记录管理
 * 
 */
public class ManageNoticeAction extends BaseAction<NoticeModel> implements ModelDriven<NoticeModel> {

	@Resource
	private NoticeService noticeService;

	private Map<String, Object> data;

	/**
	 * 信息管理
	 * 
	 * @return 返回页面
	 * @throws Exception 异常
	 */
	@Action("/modules/system/notice/manager")
	public String noticeManager() throws Exception {
		return "manager";
	}

	/**
	 * 信息列表
	 * 
	 * @throws Exception 异常
	 */
	@Action(value = "/modules/system/notice/list")
	public void noticeList() throws Exception { 
		int pageNumber = paramInt("page"); // 当前页数
		int pageSize = paramInt("rows"); // 每页每页总数
		String status = paramString("status");
		if(StringUtil.isBlank(status)){
			model.setStatus(99);
		}
		PageDataList<NoticeModel> pagaDataList = noticeService.noticeList(model, pageNumber, pageSize);
		data = new HashMap<String, Object>();
		data.put("total", pagaDataList.getPage().getTotal()); // 总行数
		data.put("rows", pagaDataList.getList()); // 集合对象
		printJson(getStringOfJpaObj(data));
	}
}